from app.repositories.sponsors_record_repo import SponsorsRecordRepo
from app.schema.sponsors_schema import SponsorRecordItem
from typing import List, Optional, Tuple
class SponsorsService:
    def __init__(self, repo: SponsorsRecordRepo):
        self.repo = repo

    def list_records(
        self,
        year_from: int,
        year_to: int,
        current: bool,
        program_id: Optional[int],
        program_code: Optional[List[str]],
        keyword: Optional[str],
        faculty: Optional[List[str]],
        coop_program: Optional[List[str]],
        page: int,
        page_size: int,
    ) -> Tuple[int, List[SponsorRecordItem]]:
        total, rows = self.repo.get_records_paginated(
            year_from, year_to, current,
            program_id, program_code, keyword, faculty, coop_program,
            page, page_size
        )
        items = [SponsorRecordItem(**r) for r in rows]
        return total, items
